/*
 * RichTextToolbarEvent.java
 *
 * Copyright (C) 2011 Thomas Everingham
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; version 3 of the License.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * A copy of the GNU General Public License can be found in the file
 * LICENSE.txt provided with the source distribution of this program (see
 * the META-INF directory in the source jar). This license can also be
 * found on the GNU website at http://www.gnu.org/licenses/gpl.html.
 *
 * If you did not receive a copy of the GNU General Public License along
 * with this program, contact the lead developer, or write to the Free
 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301, USA.
 *
 * If you find this program useful, please tell me about it! I would be delighted
 * to hear from you at tom.ingatan@gmail.com.
 */

package org.ingatan.event;

import org.ingatan.component.text.RichTextToolbar;

/**
 * Encapsulates an event as generated by a RichTextToolbar object.
 *
 * @author Thomas Everingham
 * @version 1.0
 */
public class RichTextToolbarEvent {

    /**
     * The font colour has been changed.
     */
    public final static int FONT_COLOUR_CHANGED = 0;
    /**
     * The font family has been changed.
     */
    public final static int FONT_FAMILY_CHANGED = 1;
    /**
     * The font size has changed.
     */
    public final static int FONT_SIZE_CHANGED = 2;
    /**
     * The bold button has been pressed.
     */
    public final static int BOLD_BUTTON = 3;
    /**
     * The italic button has been pressed.
     */
    public final static int ITALIC_BUTTON = 4;
    /**
     * The underline button has been pressed.
     */
    public final static int UNDERNLINE_BUTTON = 5;
    /**
     * The superscript button has been pressed.
     */
    public final static int SUPERSCRIPT_BUTTON = 6;
    /**
     * The subscript button has been pressed.
     */
    public final static int SUBSCRIPT_BUTTON = 7;
    /**
     * The justify-left button has been pressed.
     */
    public final static int JUSTIFY_LEFT = 8;
    /**
     * The justify-centre button has been pressed.
     */
    public final static int JUSTIFY_CENTRE = 9;
    /**
     * The justify-right button has been pressed.
     */
    public final static int JUSTIFY_RIGHT = 10;
    /**
     * The insert picture button has been pressed.
     */
    public final static int INSERT_PICTURE = 11;
    /**
     * The font colour button has been pressed. This does not mean that a new
     * font colour has been selected or applied.
     */
    public final static int FONT_COLOUR_BUTTON = 12;

    /**
     * The toolbar which generated this event.
     */
    private RichTextToolbar source;

    /**
     * The identifier of this event. These identifiers are accessible as fields of the
     * RichTextToolbarEvent class.
     */
    private int eventID;

    public RichTextToolbarEvent(RichTextToolbar source, int eventID) {
        this.source = source;
        this.eventID = eventID;
    }

    /**
     * Gets the RichTextToolbar that generated this event.
     * @return the RichTextToolbar that generated this event.
     */
    public RichTextToolbar getSource() {
        return source;
    }

    /**
     * Gets the identifier for this event.
     * @return the identifier for this event.
     */
    public int getEventID() {
        return eventID;
    }

    /**
     * Gets a textual description of the event encapsulated by this object.
     * @return a textual description of this event.
     */
    public String getEventText()
    {
        return getEventText(eventID);
    }

    /**
     * Gets a textual description of the event indicated by the eventID provided.
     * @param event an eventID. All IDs are fields of this class.
     * @return a textual description of the event indicated by the eventID provided.
     */
    public String getEventText(int event) {
        switch (event) {
            case 0:
                return "Font Colour Changed";
            case 1:
                return "Font Family Changed";
            case 2:
                return "Font Size Changed";
            case 3:
                return "Bold Button Pressed";
            case 4:
                return "Italic Button Pressed";
            case 5:
                return "Underline Button Pressed";
            case 6:
                return "Superscript Button Pressed";
            case 7:
                return "Subscript Button Pressed";
            case 8:
                return "Justify Left Button Pressed";
            case 9:
                return "Justify Centre Button Pressed";
            case 10:
                return "Justify Right Button Pressed";
            case 11:
                return "Insert Picture Button Pressed";
            default:
                return "Unknown Event ID";
        }
    }
}
